package com.alit.ibot.robot.wechat;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.devtools.autoconfigure.LocalDevToolsAutoConfiguration;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.Environment;

import com.alit.ibot.robot.wechat.config.ApplicationContextAwareImpl;
import com.alit.ibot.robot.wechat.config.DispatcherServletConfig;
import com.alit.ibot.robot.wechat.config.ResourcesStaticServletConfig;
import com.alit.ibot.robot.wechat.util.IPUtil;

@SpringBootConfiguration
@Import({ org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryAutoConfiguration.class,
    // LocalDevTools
    LocalDevToolsAutoConfiguration.class, DispatcherServletConfig.class, ApplicationContextAwareImpl.class,
    ResourcesStaticServletConfig.class })

public class RobotWechatApplication {
  private static Environment e;

  public static void main(String[] args) {
    long start = System.currentTimeMillis();
    SpringApplication.run(RobotWechatApplication.class, args);
    long end = System.currentTimeMillis();
    System.out.println("启动完成,使用了" + (end - start) + "ms");
    diagnosis();
    e = ApplicationContextAwareImpl.getBean(Environment.class);
    IPUtil.printAccessUrl(e.getProperty("server.port", Integer.class), e.getProperty("server.servlet.context-path"));
  }

  private static void diagnosis() {
    System.out.println("java.home:" + System.getProperty("java.home"));
  }
}